/*
 * main.cpp
 *
 *  Created on: 08/01/2012
 *      Author: Mariano
 */

#include "game/Mario.h"
#include "Graphics/Graphics.h"
#include "Graphics/AssetManager.h"
#include "events/EventHandler.h"
#include "events/KeyListener.h"
#include <iostream>
using namespace std;

int main(int argc, char * argv[]) {

	Graphics graphics(640, 480);
	graphics.setBackgroundColor(0);
	EventHandler eventHandler;
	eventHandler.addKeyListener(&graphics);

	AssetManager assetManager;

	Sprite * bg = assetManager.loadSprite("background.jpg", 0, 500, 500);
	SpriteInstance bgInstance(bg);
	graphics.addSpriteInstance(&bgInstance);

	Sprite * mario = assetManager.loadSprite("assets/slimes.jpg", 4, 80, 46);
	SpriteInstance marioInstance(mario);
	graphics.addSpriteInstance(&marioInstance);

	Mario m;
	m.setPosition(100, 100);
	m.setSpriteInstance(&marioInstance);
	eventHandler.addKeyListener(&m);

	graphics.getCamera()->setTarget(&m);

	while (graphics.update(30)) {
		eventHandler.update();
		m.update();
	}
	return 0;
}
